package com.xt.itheima.d3_interface_demo;

import java.util.ArrayList;

public class StudentOperatorImpl implements StudentOperator {
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("========= 全班全部学生信息如下 =========");
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            System.out.println("姓名" + s.getName() + "\n性别" + s.getSex() + "\n分数" + s.getScore());
        }
        System.out.println("-----------------------------------");
    }

    @Override
    public void printAverageScore(ArrayList<Student> students) {
        System.out.println("============= 全班全部学生的平均分 =============");
        double allScore = 0;
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            allScore += s.getScore();
        }
        System.out.println("平均分: " + (allScore / students.size()));
    }
}
